home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / LiveFastStartServer / Open Transport 1.3 / Includes / CIncludes / OpenTptLinks.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-30  |  6.1 KB  |  249 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OpenTptLinks.h
  3.  
  4.     Contains:    Definitions for link modules
  5.  
  6.     Copyright:    © 1994-1996 by Apple Computer, Inc., all rights reserved.
  7.  
  8.  
  9. */
  10.  
  11. #ifndef __OPENTPTLINKS__
  12. #define __OPENTPTLINKS__
  13.  
  14. #ifndef __OPENTRANSPORT__
  15. #include <OpenTransport.h>
  16. #endif
  17.  
  18. #if PRAGMA_ALIGN_SUPPORTED
  19. #pragma options align=mac68k
  20. #endif
  21.  
  22. /*******************************************************************************
  23. ** Device Types for OTPortRefs
  24. ********************************************************************************/
  25.  
  26. enum
  27. {
  28.     kOTADEVDevice            = 1,        /* An Atalk ADEV        */
  29.     kOTMDEVDevice            = 2,        /* A TCP/IP MDEV        */
  30.     kOTLocalTalkDevice        = 3,        /* LocalTalk            */
  31.     kOTIRTalkDevice            = 4,        /* IRTalk                */
  32.     kOTTokenRingDevice        = 5,        /* Token Ring            */
  33.     kOTISDNDevice            = 6,        /* ISDN                    */
  34.     kOTATMDevice            = 7,        /* ATM                    */
  35.     kOTSMDSDevice            = 8,        /* SMDS                    */
  36.     kOTSerialDevice            = 9,        /* Serial                 */
  37.     kOTEthernetDevice        = 10,        /* Ethernet                */
  38.     kOTSLIPDevice            = 11,        /* SLIP Pseudo-device    */
  39.     kOTPPPDevice            = 12,        /* PPP Pseudo-device    */
  40.     kOTModemDevice            = 13,        /* Modem Pseudo-Device    */
  41.     kOTFastEthernetDevice    = 14,        /* 100 MB Ethernet        */
  42.     kOTFDDIDevice            = 15,        /* FDDI                    */
  43.     kOTIrDADevice            = 16,        /* IrDA Infrared        */
  44.     kOTATMSNAPDevice        = 17,        /* ATM SNAP emulation    */
  45.     kOTFibreChannelDevice    = 18,        /* Fibre Channel        */
  46.     kOTFireWireDevice        = 19        /* FireWire link Device    */
  47. };
  48.  
  49. /*******************************************************************************
  50. ** Interface option flags
  51. ********************************************************************************/
  52.  
  53. enum
  54. {
  55.     //
  56.     // Ethernet framing options
  57.     //
  58.     kOTFramingEthernet        = 0x01,
  59.     kOTFramingEthernetIPX    = 0x02,
  60.     kOTFraming8023            = 0x04,
  61.     kOTFraming8022            = 0x08
  62. };
  63. /*
  64.  * These are obsolete and will be going away in OT1.5
  65.  */
  66. enum
  67. {
  68.     //
  69.     // RawMode options
  70.     //
  71.     kOTRawRcvOn                    = 0,
  72.     kOTRawRcvOff                = 1,
  73.     kOTRawRcvOnWithTimeStamp    = 2
  74. };
  75.  
  76. enum
  77. {
  78.     //
  79.     // OPT_SETPROMISCUOUS value
  80.     //
  81.     DL_PROMISC_OFF            = 0
  82. };
  83.  
  84. /*******************************************************************************
  85. ** Module definitions
  86. ********************************************************************************/
  87. //
  88. // XTI Levels
  89. //
  90. enum
  91. {
  92.     LNK_ENET    = 'ENET',
  93.     LNK_TOKN    = 'TOKN',
  94.     LNK_FDDI    = 'FDDI',
  95.     LNK_TPI        = 'LTPI'
  96. };
  97. //
  98. // Module IDs
  99. //
  100. enum
  101. {
  102.     kT8022ModuleID        = 7100,
  103.     kEnetModuleID        = 7101,
  104.     kTokenRingModuleID    = 7102,
  105.     kFDDIModuleID        = 7103
  106. };
  107. //
  108. // Module Names
  109. //
  110. #define kEnet8022Name        "enet8022x"
  111. #define kEnetName            "enet"
  112. #define kFastEnetName        "fenet"
  113. #define kTokenRingName        "tokn"
  114. #define kFDDIName            "fddi"
  115. #define kIRTalkName            "irtlk"
  116. #define kSMDSName            "smds"
  117. #define kATMName            "atm"
  118. #define kT8022Name            "tpi8022x"
  119. #define kATMSNAPName        "atmsnap"
  120. #define kFireWireName        "firewire"
  121. #define kFibreChannelName    "fibre"
  122. //
  123. // Address Family
  124. //
  125. enum
  126. {
  127.     AF_8022        = 8200    // Our 802.2 generic address family
  128. };
  129.  
  130. /*******************************************************************************
  131. ** Options
  132. ********************************************************************************/
  133.  
  134. enum
  135. {
  136.     OPT_ADDMCAST         = 0x1000,
  137.     OPT_DELMCAST         = 0x1001,
  138.     OPT_RCVPACKETTYPE    = 0x1002,
  139.     OPT_RCVDESTADDR        = 0x1003,
  140.     OPT_SETRAWMODE        = 0x1004,
  141.     OPT_SETPROMISCUOUS    = 0x1005
  142. };
  143.  
  144. enum OTPacketType
  145. {
  146.     kETypeStandard=0,
  147.     kETypeMulticast,
  148.     kETypeBroadcast,
  149.     kETRawPacketBit = 0x80000000,
  150.     kETTimeStampBit = 0x40000000
  151. };
  152.  
  153. /*******************************************************************************
  154. ** Link related constants
  155. ********************************************************************************/
  156.  
  157. enum
  158. {
  159.     //
  160.     // length of an ENET hardware addressaddress
  161.     //
  162.     kMulticastLength            = 6,
  163.     k48BitAddrLength            = 6,
  164.     //
  165.     // The protocol type is our DLSAP
  166.     //
  167.     k8022DLSAPLength            = 2,
  168.     //
  169.     k8022SNAPLength             = 5,
  170.     //
  171.     // length of an address field used by the ENET enpoint
  172.     //    = k48BitAddrLength + sizeof(protocol type)
  173.     //
  174.     kEnetAddressLength            = k48BitAddrLength + k8022DLSAPLength,
  175.     //
  176.     // Special DLSAPS for ENET
  177.     //
  178.     kSNAPSAP                    = 0x00AA,
  179.     kIPXSAP                        = 0x00FF,
  180.     kMax8022SAP                    = 0x00FE,
  181.     k8022GlobalSAP                = 0x00FF,
  182.     kMinDIXSAP                    = 1501,
  183.     kMaxDIXSAP                    = 0xFFFFU
  184. };
  185.  
  186.  
  187.  
  188. /*******************************************************************************
  189. ** Generic Address Structure
  190. ********************************************************************************/
  191.  
  192. struct T8022Address
  193. {
  194.         OTAddressType    fAddrFamily;
  195.         UInt8            fHWAddr[k48BitAddrLength];
  196.         UInt16            fSAP;
  197.         UInt8            fSNAP[k8022SNAPLength];
  198. };
  199.  
  200. enum
  201. {
  202.         k8022BasicAddressLength = sizeof(OTAddressType) + k48BitAddrLength +
  203.                                                 sizeof(UInt16),
  204.         k8022SNAPAddressLength = sizeof(OTAddressType) + k48BitAddrLength +
  205.                                     sizeof(UInt16) + k8022SNAPLength
  206. };
  207.  
  208. /*******************************************************************************
  209. ** Some helpful stuff for dealing with 48 bit addresses
  210. ********************************************************************************/
  211.  
  212. #define OTCompare48BitAddresses(p1, p2)                                                        \
  213.     (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) &&        \
  214.      *(const UInt16*)(((const UInt8*)(p1))+4) == *(const UInt16*)(((const UInt8*)(p2))+4) )
  215.  
  216. #define OTCopy48BitAddress(p1, p2)                                                \
  217.     (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)),            \
  218.      *(UInt16*)(((UInt8*)(p2))+4) = *(const UInt16*)(((const UInt8*)(p1))+4) )
  219.  
  220. #define OTClear48BitAddress(p1)                                                    \
  221.     (*(UInt32*)((UInt8*)(p1)) = 0,                                                \
  222.      *(UInt16*)(((UInt8*)(p1))+4) = 0 )
  223.  
  224. #define OTCompare8022SNAP(p1, p2)                                                        \
  225.     (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) &&    \
  226.      *(((const UInt8*)(p1))+4) == *(((const UInt8*)(p2))+4) )
  227.  
  228. #define OTCopy8022SNAP(p1, p2)                                                \
  229.     (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)),        \
  230.      *(((UInt8*)(p2))+4) = *(((const UInt8*)(p1))+4) )
  231.  
  232. #define OTIs48BitBroadcastAddress(p1)                    \
  233.     (*(UInt32*)((UInt8*)(p1)) == 0xffffffff &&            \
  234.      *(UInt16*)(((UInt8*)(p1))+4) == 0xffff )
  235.  
  236. #define OTSet48BitBroadcastAddress(p1)                    \
  237.     (*(UInt32*)((UInt8*)(p1)) = 0xffffffff,                \
  238.      *(UInt16*)(((UInt8*)(p1))+4) = 0xffff )
  239.  
  240. #define OTIs48BitZeroAddress(p1)                \
  241.     (*(UInt32*)((UInt8*)(p1)) == 0 &&             \
  242.      *(UInt16*)(((UInt8*)(p1))+4) == 0 )
  243.  
  244. #if PRAGMA_ALIGN_SUPPORTED
  245. #pragma options align=reset
  246. #endif
  247.  
  248. #endif
  249.